package com.xingyi.bacs.dao;

import com.xingyi.bacs.bean.*;
import com.xingyi.bacs.util.JDBCUtil;
import com.xingyi.bacs.util.LogUtil;
import org.springframework.stereotype.Repository;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;

/**
 * Created by wujt on 30/9/2021
 */
@Repository
public class FrDaoImpl implements FrDao{
    @Override
    public void insertRJFRAccountInfo(List<RJFRAccountInfo> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJFRAccountInfo obj = null;
        String sql = "insert into RUN_RJFR_ACCOUNTINFO (" +
                "        id," +
                "        zshh," +
                "        shh," +
                "        fkfwsbh," +
                "        fkjc," +
                "        cplx," +
                "        zzhlx," +
                "        jshm," +
                "        jskh," +
                "        sjh," +
                "        zhzt," +
                "        rzzt," +
                "        gxsj," +
                "        jsxxdrpch," +
                "        sfsc," +
                "        ssdlsdj," +
                "        sjfwsdj," +
                "        sjfwsbh," +
                "        sjfwsmc," +
                "        dgbs," +
                "        khlhh," +
                "        sjly" +
                "        ) VALUES " +
                "        (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getFkfwsbh());
                pstat.setString(5, obj.getFkjc());
                pstat.setString(6, obj.getCplx());
                pstat.setString(7, obj.getZzhlx());
                pstat.setString(8, obj.getJshm());
                pstat.setString(9, obj.getJskh());
                pstat.setString(10, obj.getSjh());
                pstat.setInt(11, obj.getZhzt());
                pstat.setString(12, obj.getRzzt());
                pstat.setString(13, obj.getGxsj());
                pstat.setString(14, obj.getJsxxdrpch());
                pstat.setInt(15, obj.getSfsc());
                pstat.setInt(16, obj.getSsdlsdj());
                pstat.setString(17, obj.getSjfwsdj());
                pstat.setString(18, obj.getSjfwsbh());
                pstat.setString(19, obj.getSjfwsmc());
                pstat.setInt(20, obj.getDgbs());
                pstat.setString(21, obj.getKhlhh());
                pstat.setInt(22, obj.getSjly());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "账户结算信息表【RJFR_ACCOUNTINFO】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "账户结算信息表【RJFR_ACCOUNTINFO】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "账户结算信息表【RJFR_ACCOUNTINFO】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertDLRAccountInfo(List<DLRAccountInfo> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        DLRAccountInfo obj = null;
        String sql = "insert into RUN_DLR_ACCOUNTINFO (" +
                "        id," +
                "        zshh," +
                "        shh," +
                "        fkfwsbh," +
                "        fkjc," +
                "        cplx," +
                "        zzhlx," +
                "        jshm," +
                "        jskh," +
                "        sjh," +
                "        zhzt," +
                "        rzzt," +
                "        gxsj," +
                "        jsxxdrpch," +
                "        sfsc," +
                "        ssdlsdj," +
                "        sjfwsdj," +
                "        sjfwsbh," +
                "        sjfwsmc," +
                "        dgbs," +
                "        khlhh," +
                "        sjly," +
                "        KHHMC" +
                "        ) VALUES " +
                "        (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getFkfwsbh());
                pstat.setString(5, obj.getFkjc());
                pstat.setString(6, obj.getCplx());
                pstat.setString(7, obj.getZzhlx());
                pstat.setString(8, obj.getJshm());
                pstat.setString(9, obj.getJskh());
                pstat.setString(10, obj.getSjh());
                pstat.setInt(11, obj.getZhzt());
                pstat.setString(12, obj.getRzzt());
                pstat.setString(13, obj.getGxsj());
                pstat.setString(14, obj.getJsxxdrpch());
                pstat.setInt(15, obj.getSfsc());
                pstat.setInt(16, obj.getSsdlsdj());
                pstat.setString(17, obj.getSjfwsdj());
                pstat.setString(18, obj.getSjfwsbh());
                pstat.setString(19, obj.getSjfwsmc());
                pstat.setInt(20, obj.getDgbs());
                pstat.setString(21, obj.getKhlhh());
                pstat.setInt(22, obj.getSjly());
                pstat.setString(23, obj.getKhhmc());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "代理人账户结算信息表【DLR_ACCOUNTINFO】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "代理人账户结算信息表【DLR_ACCOUNTINFO】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "代理人账户结算信息表【DLR_ACCOUNTINFO】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRJAccountSum(List<RJAccountSum> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJAccountSum obj = null;
        String sql = "insert into RUN_RJFR_ACCOUNTSUM (" +
                "        id," +
                "        zshh," +
                "        shh," +
                "        zzhlx," +
                "        sjh," +
                "        txzt," +
                "        cjsj," +
                "        scgxsj," +
                "        ssdlsdj" +
                "        ) VALUES " +
                "        (?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getZzhlx());
                pstat.setString(5, obj.getSjh());
                pstat.setInt(6, obj.getTxzt());
                pstat.setString(7, obj.getCjsj());
                pstat.setString(8, obj.getScgxsj());
                pstat.setInt(9, obj.getSsdlsdj());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "结算信息汇总表【RJFR_ACCOUNTSUM】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "结算信息汇总表【RJFR_ACCOUNTSUM】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "结算信息汇总表【RJFR_ACCOUNTSUM】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertDLRAccountSum(List<DLRAccountSum> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        DLRAccountSum obj = null;
        String sql = "insert into RUN_DLR_ACCOUNTSUM (" +
                "        id," +
                "        zshh," +
                "        shh," +
                "        zzhlx," +
                "        sjh," +
                "        txzt," +
                "        cjsj," +
                "        scgxsj," +
                "        ssdlsdj," +
                "        fkfwsbh" +
                "        ) VALUES " +
                "        (?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getZzhlx());
                pstat.setString(5, obj.getSjh());
                pstat.setInt(6, obj.getTxzt());
                pstat.setString(7, obj.getCjsj());
                pstat.setString(8, obj.getScgxsj());
                pstat.setInt(9, obj.getSsdlsdj());
                pstat.setString(10, obj.getFkfwsbh());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "代理人账户汇总表【DLR_ACCOUNTSUM】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "代理人账户汇总表【DLR_ACCOUNTSUM】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "代理人账户汇总表【DLR_ACCOUNTSUM】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRjfrTxWater(List<RjfrTxWater> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RjfrTxWater obj = null;
        String sql = "insert into RUN_RJFR_TX_WATER (id,zshh,shh,ssdlsdj,sjh,zzhlx,qzlsh,txddh,txrq,txsj,txjyje," +
                "txsxf,jsje,jshm,jskh,dfptlsh,dfyszt,ddzt,xgsj,appczsj,dfqrzt,dfqrsj,dffhrq,sfqrkfdf,dzzt,dgbs," +
                "zhgs,khhmc) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setInt(4, obj.getSsdlsdj());
                pstat.setString(5, obj.getSjh());
                pstat.setString(6, obj.getZzhlx());
                pstat.setString(7, obj.getQzlsh());
                pstat.setString(8, obj.getTxddh());
                pstat.setString(9, obj.getTxrq());
                pstat.setString(10, obj.getTxsj());
                pstat.setBigDecimal(11, obj.getTxjyje());
                pstat.setBigDecimal(12, obj.getTxsxf());
                pstat.setBigDecimal(13, obj.getJsje());
                pstat.setString(14, obj.getJshm());
                pstat.setString(15, obj.getJskh());
                pstat.setString(16, obj.getDfptlsh());
                pstat.setString(17, obj.getDfyszt());
                pstat.setString(18, obj.getDdzt());
                pstat.setString(19, obj.getXgsj());
                pstat.setString(20, obj.getAppczsj());
                pstat.setString(21, obj.getDfqrzt());
                pstat.setString(22, obj.getDfqrsj());
                pstat.setString(23, obj.getDffhrq());
                pstat.setInt(24, obj.getSfqrkfdf());
                pstat.setString(25, obj.getDzzt());
                pstat.setInt(26, obj.getDgbs());
                pstat.setString(27, obj.getZhgs());
                pstat.setString(28, obj.getKhhmc());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "提现流水表【RUN_RJFR_TX_WATER】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "提现流水表【RUN_RJFR_TX_WATER】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "提现流水表【RUN_RJFR_TX_WATER】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRJAccountFlow(List<RJAccountFlow> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJAccountFlow obj = null;
        String sql = "insert into RUN_RJFR_ACCOUNT_FLOW (id,lsrq,zshh,shh,zzhlx,sjh,sqye,czje,gcje," +
                "fykk,txjyje,txsxf,tzje,qmye,zhgs) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getLsrq());
                pstat.setString(3, obj.getZshh());
                pstat.setString(4, obj.getShh());
                pstat.setString(5, obj.getZzhlx());
                pstat.setString(6, obj.getSjh());
                pstat.setBigDecimal(7, obj.getSqye());
                pstat.setBigDecimal(8, obj.getCzje());
                pstat.setBigDecimal(9, obj.getGcje());
                pstat.setBigDecimal(10, obj.getFykk());
                pstat.setBigDecimal(11, obj.getTxjyje());
                pstat.setBigDecimal(12, obj.getTxsxf());
                pstat.setBigDecimal(13, obj.getTzje());
                pstat.setBigDecimal(14, obj.getQmye());
                pstat.setString(15, obj.getZhgs());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "账户流水表【RJFR_ACCOUNT_FLOW】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "账户流水表【RJFR_ACCOUNT_FLOW】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "账户流水表【RJFR_ACCOUNT_FLOW】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRJCzFrWater(List<RJCzFrWater> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJCzFrWater obj = null;
        String sql = "insert into RUN_RJFR_CZFR_WATER (id,zshh,shh,lsh,jsrq,czsj,cplx,zzhlx,ssdlsdj," +
                "fxlx,fkjc,fkfwsbh,fkfwsmc,czje,sfrj,sjh,gsdj,czzt,yjdlsbh,hdId,hdmc,zjly,yylx)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getLsh());
                pstat.setString(5, obj.getJsrq());
                pstat.setString(6, obj.getCzsj());
                pstat.setString(7, obj.getCplx());
                pstat.setString(8, obj.getZzhlx());
                pstat.setInt(9, obj.getSsdlsdj());
                pstat.setString(10, obj.getFxlx());
                pstat.setString(11, obj.getFkjc());
                pstat.setString(12, obj.getFkfwsbh());
                pstat.setString(13, obj.getFkfwsmc());
                pstat.setBigDecimal(14, obj.getCzje());
                pstat.setInt(15, obj.getSfrj());
                pstat.setString(16, obj.getSjh());
                pstat.setInt(17, obj.getGsdj());
                pstat.setInt(18, obj.getCzzt());
                pstat.setString(19, obj.getYjdlsbh());
                pstat.setString(20, obj.getHdId());
                pstat.setString(21, obj.getHdmc());
                pstat.setString(22, obj.getZjly());
                pstat.setString(23, obj.getYylx());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "充值分润流水表【RJFR_CZFR_WATER】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "充值分润流水表【RJFR_CZFR_WATER】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "充值分润流水表【RJFR_CZFR_WATER】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRJCzFxWater(List<RJCzFxWater> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJCzFxWater obj = null;
        String sql = "insert into RUN_RJFR_CZFX_WATER (id,zshh,shh,lsh,jsrq,czsj,cplx,zzhlx,ssdlsdj,fxlx," +
                "fkjc,fkfwsbh,fkfwsmc,czje,sfrj,sjh,gsdj,czzt,hdId,hdmc,yjdlsbh,yjId,yjmc,jcfxje,dffxje,yylx)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getLsh());
                pstat.setString(5, obj.getJsrq());
                pstat.setString(6, obj.getCzsj());
                pstat.setString(7, obj.getCplx());
                pstat.setString(8, obj.getZzhlx());
                pstat.setInt(9, obj.getSsdlsdj());
                pstat.setString(10, obj.getFxlx());
                pstat.setString(11, obj.getFkjc());
                pstat.setString(12, obj.getFkfwsbh());
                pstat.setString(13, obj.getFkfwsmc());
                pstat.setBigDecimal(14, obj.getCzje());
                pstat.setInt(15, obj.getSfrj());
                pstat.setString(16, obj.getSjh());
                pstat.setInt(17, obj.getGsdj());
                pstat.setInt(18, obj.getCzzt());
                pstat.setString(19, obj.getHdId());
                pstat.setString(20, obj.getHdmc());
                pstat.setString(21, obj.getYjdlsbh());
                pstat.setString(22, obj.getYjId());
                pstat.setString(23, obj.getYjmc());
                pstat.setBigDecimal(24, obj.getJcfxje());
                pstat.setBigDecimal(25, obj.getDffxje());
                pstat.setString(26, obj.getYylx());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "充值返现流水表【RJFR_CZFR_WATER】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "充值返现流水表【RJFR_CZFR_WATER】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "充值分润流水表【RJFR_CZFR_WATER】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRJFyWater(List<RJFyWater> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJFyWater obj = null;
        String sql = "insert into RUN_RJFR_FY_WATER (id,zshh,shh,lsh,jsrq,czsj,cplx,zzhlx,ssdlsdj," +
                "fkfwsbh,fkfwsmc,fymc,kkfs,fykk,sfrj,sjh,gsdj,czzt,yjdlsbh,hdId,hdmc,yylx)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getLsh());
                pstat.setString(5, obj.getJsrq());
                pstat.setString(6, obj.getCzsj());
                pstat.setString(7, obj.getCplx());
                pstat.setString(8, obj.getZzhlx());
                pstat.setInt(9, obj.getSsdlsdj());
                pstat.setString(10, obj.getFkfwsbh());
                pstat.setString(11, obj.getFkfwsmc());
                pstat.setString(12, obj.getFymc());
                pstat.setString(13, obj.getKkfs());
                pstat.setBigDecimal(14, obj.getFykk());
                pstat.setInt(15, obj.getSfrj());
                pstat.setString(16, obj.getSjh());
                pstat.setInt(17, obj.getGsdj());
                pstat.setInt(18, obj.getCzzt());
                pstat.setString(19, obj.getYjdlsbh());
                pstat.setString(20, obj.getHdId());
                pstat.setString(21, obj.getHdmc());
                pstat.setString(22, obj.getYylx());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "费用流水表【RJFR_FY_WATER】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "费用流水表【RJFR_FY_WATER】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "费用流水表【RJFR_FY_WATER】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertRJGcWater(List<RJGcWater> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        RJGcWater obj = null;
        String sql = "insert into RUN_RJFR_GC_WATER (id,zshh,shh,lsh,jsrq,czsj,cplx," +
                "zzhlx,ssdlsdj,fxlx,fkjc,fkfwsbh,fkfwsmc,gcje,sfrj,sjh,gsdj,czzt,tzyy)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getLsh());
                pstat.setString(5, obj.getJsrq());
                pstat.setString(6, obj.getCzsj());
                pstat.setString(7, obj.getCplx());
                pstat.setString(8, obj.getZzhlx());
                pstat.setInt(9, obj.getSsdlsdj());
                pstat.setString(10, obj.getFxlx());
                pstat.setString(11, obj.getFkjc());
                pstat.setString(12, obj.getFkfwsbh());
                pstat.setString(13, obj.getFkfwsmc());
                pstat.setBigDecimal(14, obj.getGcje());
                pstat.setInt(15, obj.getSfrj());
                pstat.setString(16, obj.getSjh());
                pstat.setInt(17, obj.getGsdj());
                pstat.setInt(18, obj.getCzzt());
                pstat.setString(19, obj.getTzyy());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "轧差流水表【RJFR_GC_WATER】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "轧差流水表【RJFR_GC_WATER】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "轧差流水表【RJFR_GC_WATER】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertMJDetailWater(List<MJDetailWater> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        MJDetailWater obj = null;
        String sql = "insert into RUN_MJ_DETAIL_WATER (id,zshh,shh,sjh,czpch,lyId,lsh,zzhlx,cplx,hznyr," +
                "jyrq,jysj,shbh,shmc,dlsbh,dlsmc,dlsdj,jllx,yxbs,zdsn,yhckh,jyje,zzsy,sylx,sfrj,hdId,zjly)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getSjh());
                pstat.setString(5, obj.getCzpch());
                pstat.setLong(6, obj.getLyId());
                pstat.setString(7, obj.getLsh());
                pstat.setString(8, obj.getZzhlx());
                pstat.setString(9, obj.getCplx());
                pstat.setString(10, obj.getHznyr());
                pstat.setString(11, obj.getJyrq());
                pstat.setString(12, obj.getJysj());
                pstat.setString(13, obj.getShbh());
                pstat.setString(14, obj.getShmc());
                pstat.setString(15, obj.getDlsbh());
                pstat.setString(16, obj.getDlsmc());
                pstat.setString(17, obj.getDlsdj());
                pstat.setString(18, obj.getJllx());
                pstat.setInt(19, obj.getYxbs());
                pstat.setString(20, obj.getZdsn());
                pstat.setString(21, obj.getYhckh());
                pstat.setBigDecimal(22, obj.getJyje());
                pstat.setBigDecimal(23, obj.getZzsy());
                pstat.setInt(24, obj.getSylx());
                pstat.setInt(25, obj.getSfrj());
                pstat.setString(26, obj.getHdId());
                pstat.setString(27, obj.getZjly());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "秒结明细流水表【MJ_DETAIL_WATER】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "秒结明细流水表【MJ_DETAIL_WATER】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "秒结明细流水表【MJ_DETAIL_WATER】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertTbAccountInfo(List<TbAccountInfo> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        TbAccountInfo obj = null;
        String sql = "insert into RUN_TB_ACCOUNTINFO (id,zshh,shh,fkfwsbh,fkjc,cplx,zzhlx,jshm," +
                "jskh,sjh,jsxxdrpch,ssdlsdj,sjfwsdj,sjfwsbh,sjfwsmc,lygxsj,gsdj,sjzt,dgbs,khlhh)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getFkfwsbh());
                pstat.setString(5, obj.getFkjc());
                pstat.setString(6, obj.getCplx());
                pstat.setString(7, obj.getZzhlx());
                pstat.setString(8, obj.getJshm());
                pstat.setString(9, obj.getJskh());
                pstat.setString(10, obj.getSjh());
                pstat.setString(11, obj.getJsxxdrpch());
                pstat.setInt(12, obj.getSsdlsdj());
                pstat.setString(13, obj.getSjfwsdj());
                pstat.setString(14, obj.getSjfwsbh());
                pstat.setString(15, obj.getSjfwsmc());
                pstat.setString(16, obj.getLygxsj());
                pstat.setInt(17, obj.getGsdj());
                pstat.setInt(18, obj.getSjzt());
                pstat.setInt(19, obj.getDgbs());
                pstat.setString(20, obj.getKhlhh());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "同步结算信息表【TB_ACCOUNTINFO】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "同步结算信息表【TB_ACCOUNTINFO】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "同步结算信息表【TB_ACCOUNTINFO】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }

    @Override
    public void insertDLRTbAccountInfo(List<DLRTbAccountInfo> list) {
        long startTime = System.currentTimeMillis();
        Connection conn = null;
        PreparedStatement pstat = null;
        DLRTbAccountInfo obj = null;
        String sql = "insert into RUN_DLR_TB_ACCOUNTINFO (id,zshh,shh,fkfwsbh,fkjc,cplx,zzhlx,jshm," +
                "jskh,sjh,jsxxdrpch,ssdlsdj,sjfwsdj,sjfwsbh,sjfwsmc,lygxsj,gsdj,sjzt,dgbs,khlhh,khhmc)" +
                " VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
        try {
            conn = JDBCUtil.getFRConn();
            pstat = conn.prepareStatement(sql);
            conn.setAutoCommit(false);
            for(int i=0;i<list.size();i++){
                obj = list.get(i);
                pstat.setLong(1, obj.getId());
                pstat.setString(2, obj.getZshh());
                pstat.setString(3, obj.getShh());
                pstat.setString(4, obj.getFkfwsbh());
                pstat.setString(5, obj.getFkjc());
                pstat.setString(6, obj.getCplx());
                pstat.setString(7, obj.getZzhlx());
                pstat.setString(8, obj.getJshm());
                pstat.setString(9, obj.getJskh());
                pstat.setString(10, obj.getSjh());
                pstat.setString(11, obj.getJsxxdrpch());
                pstat.setInt(12, obj.getSsdlsdj());
                pstat.setString(13, obj.getSjfwsdj());
                pstat.setString(14, obj.getSjfwsbh());
                pstat.setString(15, obj.getSjfwsmc());
                pstat.setString(16, obj.getLygxsj());
                pstat.setInt(17, obj.getGsdj());
                pstat.setInt(18, obj.getSjzt());
                pstat.setInt(19, obj.getDgbs());
                pstat.setString(20, obj.getKhlhh());
                pstat.setString(21, obj.getKhhmc());
                pstat.addBatch();
                if (i%2000==0&&i>0) {
                    pstat.executeBatch();
                    conn.commit();
                    LogUtil.info(this.getClass(), "代理人同步结算信息表【DLR_TB_ACCOUNTINFO】分批保存条数至："+i);
                }
            }
            pstat.executeBatch();
            conn.commit();
            long endTime = System.currentTimeMillis();
            LogUtil.info(this.getClass(), "代理人同步结算信息表【DLR_TB_ACCOUNTINFO】分批保存条数至："+list.size()+"，耗时："+(endTime-startTime)/1000);
        } catch (Exception e) {
            e.printStackTrace();
            if(conn!=null){
                try {
                    conn.rollback();
                    LogUtil.info(this.getClass(), "代理人同步结算信息表【DLR_TB_ACCOUNTINFO】分批次保存异常数据进行回滚！");
                } catch (SQLException e1) {
                    e1.printStackTrace();
                }
            }
            throw new RuntimeException(e.getMessage());
        } finally {
            JDBCUtil.getClose(conn, pstat, null);
        }
    }
}
